package com.itheima.d3_collection_traverse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

/**
 *       目标：完成电影信息的展示。
 *       new Movie("《肖生克的救赎》" , 9.7 ,  "罗宾斯")
 *       new Movie("《霸王别姬》" , 9.6 ,  "张国荣、张丰毅")
 *       new Movie("《阿甘正传》" , 9.5 ,  "汤姆.汉克斯")
 */
public class CollectionTest04 {
    public static void main(String[] args) {
        Collection<Movie> coll = new ArrayList<>();
        coll.add(new Movie("《肖生克的救赎》" , 9.7 ,  "罗宾斯"));
        coll.add(new Movie("《霸王别姬》" , 9.6 ,  "张国荣、张丰毅"));
        coll.add(new Movie("《阿甘正传》" , 9.5 ,  "汤姆.汉克斯"));
        coll.forEach(System.out::println);
        System.out.println("==========================");
        Iterator<Movie> it = coll.iterator();
        while (it.hasNext()){
            Movie m = it.next();
            System.out.println(m);
        }
        System.out.println("==========================");
        for (Movie m : coll) {
            System.out.println(m);
        }
        System.out.println("==========================");
        coll.forEach((m)->System.out.println(m));
    }
}
